<?php
include "config/koneksi.php";
include "config/tanggalan.php";
define('FPDF_FONTPATH','config/fpdf/font/');
require('config/fpdf/fpdf.php');

$id=$_GET['id'];
$sql="select a.*,b.proli,(
       IFNULL((
          SELECT 
            SUM(nilai) 
          FROM
            tb_sertifikat 
          WHERE id_pendaftar = a.id_pendaftaran
          ),0)
      )AS nilai_sert,
(
      (4 * matematika) + (1 * indonesia) + (3 * inggris) + (2 * ipa)
    ) AS jumlah 	  from tb_pendaftar a left join tb_proli b on a.proli=b.kd_proli where id_pendaftaran='".$id."'";
$qry=mysql_query($sql);
$hasil=mysql_fetch_array($qry);
$pdf=new FPDF('P','mm',array(210,297)); 
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->Cell(180,7,'PEMERINTAH KABUPATEN KEBUMEN',0,1,'C',false);
$pdf->Cell(180,7,'DINAS PENDIDIKAN PEMUDA DAN OLAH RAGA',0,1,'C',false);
$pdf->SetFont('Arial','',12);
$pdf->Cell(180,7,'SMK NEGERI 1 KEBUMEN',0,1,'C',false);
$pdf->SetFont('Arial','',10);
$pdf->Cell(180,7,'BIDANG STUDI KEAHLIAN BISMAN DAN TEK.INFOKOM',0,1,'C',false);
$pdf->SetFont('Arial','',5);
$pdf->Cell(180,7,'Jl. Cemara 37 Karangsari Telp./Fax. TU : (0287)381132-KS : 383819 Kebumen 54351',0,1,'C',false);
$pdf->SetFont('Arial','',11);
$pdf->Ln(0);
$pdf->Cell(200,5,'_____________________________________________________________________________________',0,1,'L',false);
$pdf->Ln();
$pdf->SetFont('Arial','',10);
$pdf->Cell(180,7,'DATA PENDAFTARAN',0,1,'C',false);
$pdf->Cell(180,7,'CALON PESERTA DIDIK BARU',0,1,'C',false);
$pdf->Cell(180,7,'TAHUN PELAJARAN 2015/2016',0,1,'C',false);
$pdf->Ln();

$pdf->Cell(40,5,'Tanggal Daftar',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(150,5,tanggalan($hasil['tgl_daftar']),0,1,'L',false);

$pdf->Cell(40,5,'Program Keahlian',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['proli'],0,1,'L',false);

$pdf->Cell(40,5,'No Pendaftaran',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['no_pendaftaran'],0,1,'L',false);

$pdf->Cell(40,5,'Nama',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['nama'],0,1,'L',false);

$pdf->Cell(40,5,'Tanggal Lahir',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['tgl_lahir'],0,1,'L',false);

$pdf->Cell(40,5,'Agama',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['agama'],0,1,'L',false);

$pdf->Cell(40,5,'Nama Orang tua',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['nama_ortu'],0,1,'L',false);

$pdf->Cell(40,5,'Pekerjaan Orang tua',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['pekerjaan_ortu'],0,1,'L',false);

$pdf->Cell(40,5,'Alamat',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['alamat'],0,1,'L',false);

$pdf->Cell(40,5,'No. Hp.',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['no_hp'],0,1,'L',false);

$pdf->Cell(40,5,'Asal Sekolah',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['asal_sekolah'],0,1,'L',false);

$pdf->Cell(40,5,'Matematika',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['matematika'],0,1,'L',false);

$pdf->Cell(40,5,'Bhs.Indonesia',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['indonesia'],0,1,'L',false);

$pdf->Cell(40,5,'Bhs.Inggris',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['inggris'],0,1,'L',false);

$pdf->Cell(40,5,'IPA',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['ipa'],0,1,'L',false);

$pdf->Cell(40,5,'Total Nilai',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['jumlah'],0,1,'L',false);

$pdf->Cell(40,5,'Sertifikat',0,0,'L',false);
$pdf->Cell(3,5,':',0,0,'L',false);
$pdf->Cell(130,5,$hasil['nilai_sert'],0,1,'L',false);


//posisi gambar
$pdf->Image('images/Kebumen.jpg',10,10,30,30);
$pdf->Image('images/ex_foto.jpg',10,200,30,40);
$pdf->Image('images/smk_kebumen.jpg',160,10,30,30);
$pdf->Ln(4);
$pdf->SetFont('Arial','',9);
$pdf->Cell(140,5,'* HARAP MEYERAHKAN DATA INI DENGAN DILAMPIRI :',0,0,'L',false);
$pdf->Ln(4);
$pdf->Cell(140,5,'1. SKHUN asli 1 lembar ',0,0,'L',false);
$pdf->Ln(4);
$pdf->Cell(140,5,'2. FC SKHUN yang dilegalisir 1 lembar',0,0,'L',false);
$pdf->Ln(4);
$pdf->Cell(140,5,'3. FC Ijazah yang dilegalisir 1 lembar',0,0,'L',false);
$pdf->Ln(4);
$pdf->Cell(140,5,'4. Pas foto 3 x 4 3 lembar',0,0,'L',false);

$pdf->Output();
//urutan nama file adalah no_invoice-nama desain
$nama_file=$hasil['no_invoice'].'-'.$hasil['nama_desain'].'.pdf';
?>